
export const actions = {
    'CHANGE_NOW': Symbol(),
}

//获取当前时间
export const getNow = function () {
    const now = new Date();
    const hour = now.getHours();
    let second = now.getSeconds();
    let minute = now.getMinutes();
    let milliseconds = now.getMilliseconds();

    if (minute < 10) {
        minute = '0' + minute;
    }
    if (second < 10) {
        second = '0' + second;
    }
    if (milliseconds < 10) {
        milliseconds = '00' + milliseconds;
    } else if (milliseconds < 100) {
        milliseconds = '0' + milliseconds;
    }

    return `${hour}:${minute}:${second}:${milliseconds}`;
}


//修改当前时间，同步操作
export const setNow = () => dispatch => {
    dispatch({
        type: actions.CHANGE_NOW,
        data: getNow()
    });
};
